package com.ohuang.launcher;

import android.Manifest;
import android.app.Activity;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Process;
import android.widget.TextView;

import com.ohuang.launcher.test.A;
import com.ohuang.launcher.util.ActivityInterceptor;
import com.ohuang.launcher.util.DialogUtil;
import com.ohuang.launcher.util.PermissionUtil;
import com.ohuang.launcher.util.ProcessUtil;

import java.util.ArrayList;
import java.util.List;

public class TestActivity extends Activity {
    private final List<String> permissionList = new ArrayList<>();
    private final List<String> PERMISSIONS = new ArrayList<>();
    private static final int REQUEST_CODE = 7722;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        TextView textView=new  TextView(this);
        textView.setText("哈喽啊");
        setContentView(textView);
        requestPermission();

    }
    public void requestPermission() {
        PERMISSIONS.add("android.permission.WRITE_EXTERNAL_STORAGE");
        // 6.0及以上获取没有申请的权限
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            for (String permission : PERMISSIONS) {
                int checkSelfPermission = checkPermission(permission, Process.myPid(), Process.myUid());
                if (PackageManager.PERMISSION_GRANTED == checkSelfPermission) {
                    continue;
                }
                permissionList.add(permission);
            }
        }
        if (!permissionList.isEmpty()) {
            // 存在未申请的权限则先申请
            requestPermissions( permissionList.toArray(new String[0]), REQUEST_CODE);
        }
    }


    public void aa(String s){
        ActivityInterceptor.hook();
    }
    public void process(){
        boolean mainProcess = ProcessUtil.isMainProcess(this);
        String s=null;
        if (mainProcess){
            s="main";
        }else {
            s="NotMain";
        }
        aa(s);
    }
    public void list(){
        List<String> list=new ArrayList<>();
    }

    public void array(){
        A[] a=new A[0];
        int aSize = getASize(a);
    }
    public int getASize(A[] a){
        return a.length;
    }

}
